﻿// DEBUG
var __DEBUG__ = true;
function varDump(v, values, lookFor, includeFunctions)
{
	if (values == null)
		values = false;
	if (lookFor == null)
		lookFor = "";
	if (includeFunctions == null)
		includeFunctions = false;


	lookFor = new RegExp(lookFor, "i");
	var s = "";
	for (var k in v)
	{
		if (!lookFor.test(k) || (!includeFunctions && typeof (v[k]) === "function"))
			continue;

		s += k + (values ? "=" + v[k] : "") + ", ";
	}
	return s;
}
function log(s)
{
	if (!__DEBUG__) return;
	if (typeof (console) != "undefined")
		console.log(s);
	else
	{
		if ($("divLog") == null)
		{
			var divLog = document.createElement("div");
			divLog.id = "divLog";
			divLog.style["position"] = "absolute";
			divLog.style["color"] = "Red";
			divLog.style["right"] = "0px";
			divLog.style["width"] = "300px";
			divLog.style["height"] = "300px";
			divLog.style["overflowY"] = "auto";
			divLog.style["backgroundColor"] = "#eeeeee";
			divLog.style["fontSize"] = "12px";
			document.body.insertBefore(divLog, document.body.childNodes[0]);
		}
		var divEntry = document.createElement("div");
		$("divLog").appendChild(divEntry);
		divEntry.innerHTML = s;

		$("divLog").scrollTop = $("divLog").scrollHeight - $("divLog").offsetHeight;
	}
}
